#!/bin/bash

echo -e -n "\e[31;40m 必须要先设置主机名且必须相同(y/n): \e[0m";
read pan
echo -n "输入mysql1的ip地址:"
read mysql1
echo -n "输入mysql2的ip地址:"
read mysql2

sed -i "$a$mysql1 mysql1" /etc/hosts
sed -i "$a$mysql2 mysql2" /etc/hosts
sed -i '$a192.168.200.13 mycat' /etc/hosts


cd /etc/yum.repos.d/

rm -rvf *

cat >>centos.repo<<OK
[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enable=1
[gpmall]
name=gpmall
baseurl=file:///opt/gpmall-repo
gpgcheck=0
enable=1
OK

cd

mount -o loop CentOS-7-x86_64-DVD-1511.iso /mnt/
mkdir /opt/centos
cp -rvf /mnt/* /opt/centos
umount /mnt/

cp -rvf /root/gpmall-repo /opt/

yum clean all
yum install vsftpd -y
yum install -y mariadb mariadb-server
sed -i '$ianon_root=/opt/' /etc/vsftpd/vsftpd.conf

systemctl restart mariadb
systemctl restart vsftpd
systemctl enable vsftpd

sed -i '$a[mysqld]' /etc/my.cnf
sed -i '$alog_bin = mysql-bin' /etc/my.cnf
sed -i '$abinlog_ignore_db = mysql' /etc/my.cnf
sed -i '$aserver_id = 10' /etc/my.cnf
systemctl restart mariadb


sed -i 's/SELINUX=enforcing/SELINUX=permissive/g' /etc/selinux/config

systemctl stop firewalld.service
systemctl disable firewalld.service
iptables -F
iptables -X
iptables -Z
service iptables save

mysql -uroot -p

